package com.example.mediamoudle.preview

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.base.BaseActivity
import com.example.mediamoudle.R
import com.example.mediamoudle.databinding.ActivityPreviewMainBinding
import com.example.mediamoudle.router.MediaRouterPath
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.listener.GSYVideoProgressListener
import com.shuyu.gsyvideoplayer.player.PlayerFactory

@Route(path = MediaRouterPath.MEDIA_PREVIEW)
class PreviewMainActivity : BaseActivity<ActivityPreviewMainBinding>() {


    override fun getLayoutId(): Int =R.layout.activity_preview_main
    private var url ="http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4"
    private var url2 = "http://v.weishi.qq.com/njc_1047_1047_0bc3fqahaaaa5iafsfitevrbolaeoa5qa5ca.f70.mp4?dis_k=ccd3cca2fa20c4ff4f5e0ef85d7a9381&dis_t=1653382935&fromtag=0&pver=4.0.0&wsadapt=_0524170215__196694203_0_0_0_27_27_0_0_0_0_0&qua=V1_HT5_QZ_3.0.0_001_IDC_NEW "

    override fun initView() {

        mBinding.previewPlayer.isOpenPreView = true
       mBinding.previewPlayer.setUp(url,false,"测试")
       mBinding.previewPlayer.startPlayLogic()
        mBinding.seekBarPictiure.setVideoUrl(url)

        mBinding.previewPlayer.setGSYVideoProgressListener { progress, secProgress, currentPosition, duration ->
            Log.i("tag123", "initView: progress->$progress,currentPosition->$currentPosition ，duration->$duration")
        mBinding.seekBarPictiure.setVideoDuration(duration)
        mBinding.seekBarPictiure.setCurrentDuration(currentPosition)
        }
        mBinding.seekBarPictiure.setSeekBarProgressListener {
            Log.i("tag123", "当前播放进度: progress->$it")
            mBinding.previewPlayer.playPosition = it
        }

    }

    override fun onPause() {
        super.onPause()
        GSYVideoManager.onPause()
    }

    override fun onResume() {
        super.onResume()
        GSYVideoManager.onResume()
    }
    override fun onDestroy() {
        super.onDestroy()
        GSYVideoManager.releaseAllVideos()
    }
    override fun initListener() {

    }
}